package TestThread;
public class demo4 {
    public static int result;
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0; i <= 10000; i++) {
                result += i;
            }
            System.out.println("新线程结束");
        });
        System.out.println(thread.getState());//NEW
        thread.start();
        System.out.println(thread.getState());//RUNNABLE
        thread.join();
        System.out.println(thread.getState());//TERMINATED
        System.out.println(result);
    }
}
